package shplate

class DuringProTrackRcdController {

    def commonDataService
    def dynamicQueryService
    def index(Integer max) {
        def cellList = org.kdx.DataUtils.getCellList()
        def pageSizeList = org.kdx.DataUtils.getPageSizeList()

        [totalCount: 5, pageSize: 20, pageCurrent: 1, orderField: 'id', orderDirection: 'asc', pageSizeList: pageSizeList, cellList: cellList]
    }

    def duringProTrackRcd(){
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10,20,50,100]

        params.SYS_QUERY_NAME = 'duringProTrackRcd'
        def duringProTrackRcd = dynamicQueryService.queryForList(params)
        def tableHeadList =  []
        if(duringProTrackRcd.size()>0){
            tableHeadList =  duringProTrackRcd[0].keySet()
        }
        params.SYS_QUERY_NAME = 'duringProTrackRcdCount'
        def totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
        params.SYS_QUERY_NAME = 'orgList'
        def orgList = dynamicQueryService.queryForList(params)
        [tableHeadList:tableHeadList, pageSizeList:pageSizeList,pageSize:pageSize,totalCount:totalCount, startno:params.startno?:'',endno:params.endno?:'',
         duringProTrackRcd:duringProTrackRcd,orgList:orgList,
        startTime:params.startTime?:'',endTime:params.endTime?:'',org:params.org?:'']

    }
    def exportExcelduringProTrackrcd() {
        println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
        params.startno = 1
        params.endno = 5000
        def sysQueryName = params.SYS_QUERY_NAME


        params.SYS_QUERY_NAME= 'duringProTrackRcd'
        def duringProTrackRcd = dynamicQueryService.queryForList(params)

        def tableHeadList =  []
        if(duringProTrackRcd.size()>0){
            tableHeadList =  duringProTrackRcd[0].keySet()
        }




        String filename = new String("${sysQueryName}.xls".getBytes("UTF-8"), "UTF-8");
        response.setContentType('application/vnd.ms-excel;charset=UTF-8')
        response.setHeader('Content-disposition', "attachment;filename=${filename};charset=UTF-8")
        response.setCharacterEncoding("UTF-8");
        render(template: "export${params.EXPORT_CONTENT_NAME}",
                model:  [duringProTrackRcd:duringProTrackRcd,tableHeadList:tableHeadList
                ])
    }
}
